package com.gzhryc.servlet;

import java.io.File;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import com.gzhryc.common.logging.Logger;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;

public abstract class AbsHttpServlet extends HttpServlet{

	private static final long serialVersionUID = 1L;

	static Logger log = Logger.getLogger(AbsHttpServlet.class);

	protected DiskFileItemFactory fileItemFactory;

	@Override
	public void init(ServletConfig config) throws ServletException {
		super.init(config);
		fileItemFactory = new DiskFileItemFactory();
		File repository = (File) config.getServletContext().getAttribute("javax.servlet.context.tempdir");
		if(repository != null) {
			log.info("上传临时目录：" + repository.getPath());
		}
		fileItemFactory.setRepository(repository);
	}
}
